package com.example.xm.controller;
import com.example.xm.entity.Huiyuanentity;
import com.example.xm.entity.Typeentity;
import com.example.xm.entity.dto.TypeDto;
import com.example.xm.service.HuiyuanService;
import com.example.xm.service.TypeService;
import com.example.xm.web.Result;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/huiyuan")
public class HuiyuanController {
    @Autowired(required = false)
    HuiyuanService typeService;
    @PostMapping("/reg")
    public Result reg(@RequestBody Huiyuanentity typeentity){
        typeService.reg(typeentity);
        return Result.success();
    }
    @PostMapping("/update")
    public Result update(@RequestBody Huiyuanentity typeentity){
//        System.out.println(account+"=========="+password);
      typeService.update(typeentity);
        return Result.success();

    }
    @GetMapping("/list")
    public Result list(TypeDto dto){
        PageInfo<Huiyuanentity> pageInfo= typeService.list(dto);
        return Result.success(pageInfo);
    }
    @DeleteMapping("/delete/{ids}")
    public Result delete(@PathVariable String ids){
        String[] split = ids.split(",");
        int[] intArray = new int[split.length];
        for (int i = 0; i < split.length; i++) {
            intArray[i] = Integer.parseInt(split[i]);
        }
        typeService.delete(intArray);
        return Result.success();
    }
}
